#ifndef __XKK_TIMERTHREAD_H__
#define __XKK_TIMERTHREAD_H__

#include "Timer.hpp"
#include "Thread.hpp"

#include <functional>
using std::function;
using std::bind;

namespace xkk
{

class TimerThread
{
    using TimerCallback = function<void()>;
public:
    TimerThread(TimerCallback &&cb,int initialTime,int periodicTime) 
        :_timer(std::move(cb),initialTime,periodicTime)
         ,_thread(bind(&Timer::start,&_timer))
    {}

    void start()
    {
        _thread.start();
    }

    void stop()
    {
        _timer.stop();
        _thread.join();
    }
private:
    Timer _timer;
    Thread _thread;

};

}//namespace xkk
#endif
